function ajax(success=true) {
    return new Promise((resolve,reject)=>{
        setTimeout(()=>{
            if(success){
                resolve('Ajax data.');
            }else{
                reject('Ajax error.');
            }
        },Math.random()*100|0);
    });
}


test('async resolve',async ()=>{
    let data=await ajax();
    expect(data).toBe('Ajax data.');
});

test('async reject',async ()=>{
    try{
        await ajax();
    }catch(err){
        expect(err).toMatch('error');
    }
});